package com.cupdata.search;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

/**   
 * @Title: SearcherUtil.java 
 * @Description: TODO
 * @author dongliangwu
 * @date 2017年2月21日
 * @version V1.0   
 */
public class SearcherUtil {
	private Directory directory;
	private IndexReader reader;
	private String[] ids = {"1","2","3","4","5","6"};
	private String[] emails = {"aa@aa.org","bb@bb.org","cc@cc.org","dd@sina.org","ee@ee.edu","ff@ff.org"};
	private String[] contents = {
			"welcome to visited the space,I like book",
			"hello boy, I like pingpeng ball",
			"my name is cc I like game",
			"I like football",
			"I like football and I like basketball too",
			"I like movie and swim"
	};
	private Date[] dates = null;
	private int[] attachs = {2,3,1,4,5,5};
	private String[] names = {"zhangsan","lisi","john","jetty","mike","jake"};
	private Map<String,Float> scores = new HashMap<String,Float>();
	
	public SearcherUtil() {
		try {
			directory = FSDirectory.open(new File("d:/lucene/index1"));
//			setDate();
			scores.put("aa.org", 2.0f);
			scores.put("dd.org", 1.5f);
			index();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void setDates(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		try {
			dates = new Date[ids.length];
			dates[0] = sdf.parse("2017-02-19");
			dates[1] = sdf.parse("2017-01-11");
			dates[2] = sdf.parse("2017-09-19");
			dates[3] = sdf.parse("2017-12-22");
			dates[4] = sdf.parse("2017-01-01");
			dates[5] = sdf.parse("2017-05-19");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 
	 */
	private void index() {
		IndexWriter writer = null;
		
	}
}
